package day03_oop_code.com.itheima.d6_enum2;

public class Test {
    public static void main(String[] args) {
        System.out.println("handleData(5.52,Constant.HALF_UP) = " + handleData(5.52, Constant.HALF_UP));
        System.out.println("handleData(5.442,Constant.Down) = " + handleData(5.442, Constant.Down));
        System.out.println("handleData(3.55,Constant.Up) = " + handleData(3.55, Constant.Up));
    }

    public static double handleData(double number, int flag){
        switch (flag){
            case Constant.Down:
                number = Math.floor(number);
                break;
            case Constant.Up:
                number = Math.ceil(number);
                break;
            case Constant.HALF_UP:
                number = Math.round(number);
                break;
            case Constant.DELETE_LEFT:
                number = (int) number;
                break;
        }
        return number;
    }
}
